<template>
    <div class="container container-demanddetail">
        <a-spin tip="Loading..." :spinning="loading">
            <DemandTopVue :showBtn="true" :detailInfo="detailInfo" />
            <div class="page-panell">
                <div class="panel-title">
                    <div class="panel-content">技术简介</div>
                </div>
                <div class="panel-content word-content">
                    <template v-if="detailInfo.technicalDescription">
                        <div class="content-list" v-for="item in detailInfo.technicalDescription.split('\n')">
                            {{item}}
                        </div>
                    </template>
                </div>
            </div>
            <div class="page-panel">
                <div class="panel-title">
                    <div class="panel-content">其他</div>
                </div>
                <div class="panel-content word-content">
                    <template v-if="detailInfo.otherDetails">
                        <div class="content-list" v-for="item in detailInfo.otherDetails.split('\n')">
                            {{item}}
                        </div>
                    </template>
                    <div class="content-list" v-else>无</div>
                </div>
            </div>
            <div class="page-panel">

                <div class="panel-title">
                    <div class="panel-content">需求描述</div>
                </div>
                <div class="panel-content word-content">
                    <div v-html="detailInfo.synopsis"></div>
                </div>
            </div>
            <div class="page-panel" style="background-color:#fff;padding-bottom:80px" v-if="achievementS.length>0">
                <div class="panel-content">
                    <div class="bottom-title">匹配成果</div>
                    <div class="bottom-listbox">
                        <template v-for="(item,idx) in achievementS">
                            <div class="bottom-list" v-if="idx<2">
                                <div class="bottom-img-box">
                                    <img class="bottom-left-img" :src="item.coverPicture" />
                                </div>

                                <div class="b-l-right">
                                    <div class="b-l-title text-nowarp">{{item.achievementName}}</div>
                                    <div class="b-l-info">
                                        <template v-for="(item,idx) in item.belongToTechnologyCategory">
                                            <div class="my-type-list" :key="item" v-if="idx<3">
                                                {{item}}
                                            </div>
                                        </template>

                                    </div>
                                    <div class="b-l-info">发布人：{{item.issuer}}</div>
                                    <div class="b-l-info" v-if="item.location">
                                        {{item.location.province + item.location.city + item.location.district}}
                                    </div>
                                    <!-- <div class="b-l-bottom text-nowarp">上海医疗科技有限公司</div> -->
                                </div>
                            </div>

                        </template>
                    </div>

                </div>

            </div>
        </a-spin>
    </div>
</template>

<script lang="ts">
import api from "@/api/api";
import { UserModule } from "@/store/modules/userModules";
import { getStorageUserInfo } from "@/utils";
import { Vue, Component } from "vue-property-decorator";
import DemandTopVue from "./components/demandTop.vue";
@Component({
    name: "dom",
    components: { DemandTopVue },
})
export default class index extends Vue {
    loading = false;
    pageId = "";
    mounted() {
        const userInfo = getStorageUserInfo();
        if (!userInfo || !userInfo.token) {
            UserModule.setShowLoginPanel(true)
            this.$message.warning("登录失效");
            this.$router.go(-1);
            return;
        }
        const query = this.$route.query;
        this.pageId = query.id ? query.id + "" : "";
        this.loading = true;
        Promise.all([this.getRecommend(), this.getDetail()]).then(() => {
            this.loading = false;
        });
    }

    detailInfo = {};
    async getDetail() {
        try {
            const res = await api.getDemandList({
                id: this.pageId,
            });
            this.detailInfo = res.data;
        } finally {
            // this.loading = false;
        }
    }

    achievementS = [];
    userS = [];
    async getRecommend() {
        try {
            const res = await api.getRecommendList({ demandId: this.pageId });
            this.achievementS = res.data.achievementS ||[];
            this.userS = res.data.userS ||[];
        } finally {
            //this.loading = false;
        }
    }
}
</script>

<style lang="scss">
.container-demanddetail {
    .panel-content {
        width: 1350px;
        margin: 0 auto;
    }
    .panel-title {
        font-weight: bold;
        font-size: 22px;
        color: #2f65f3;
        background-color: #fff;

        .panel-content {
            height: 40px;
            display: flex;
            align-items: center;
        }
        .panel-content::before {
            content: "";
            display: inline-block;
            height: 26px;
            width: 1px;
            border-right: 3px solid #2f65f3;
            margin-right: 20px;
        }
    }

    .word-content {
        padding: 30px 15px;
    }

    .content-list {
        font-size: 16px;
        color: #2d2d2d;
        line-height: 30px;
        position: relative;
    }
    .content-list::before {
        content: "";
        display: inline-block;
        width: 6px;
        height: 6px;
        border-radius: 8px;
        background-color: #2f65f3;
        position: absolute;
        left: -15px;
        top: 12px;
    }

    .bottom-title {
        text-align: center;
        font-weight: bold;
        font-size: 32px;
        color: #132042;
        padding: 60px;
    }
    .bottom-listbox {
    }
    .bottom-list {
        display: inline-flex;
        width: 49%;
        box-shadow: 0px 0px 14px 4px rgba(0, 0, 0, 0.1);
        padding: 10px 0;
        margin-right: 2%;
        vertical-align: top;
        border-radius: 8px;
    }
    .bottom-list:nth-child(2n) {
        margin-right: 0;
    }

    .bottom-img-box {
        width: 336px;
        height: 176px;
        margin-right: 15px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .bottom-left-img {
        max-width: 100%;
        max-height: 100%;
        border-radius: 8px;
    }
    .b-l-right {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .b-l-title {
        font-weight: bold;
        font-size: 18px;
        color: #333333;
    }
    .b-l-type {
        background: rgba(4, 209, 103, 0.1);
        font-size: 14px;
        color: #04d167;
        display: inline-block;
        padding: 2px 10px;
        border-radius: 4px;
        margin-top: 10px;
    }
    .b-l-info {
        font-size: 14px;
        color: #333;
        margin-top: 10px;
    }
    .b-l-bottom {
        font-size: 14px;
        color: #505050;
        margin-top: 20px;
    }
}
</style>
